package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.dao.BookDao;
import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.sql.DataSource;
import java.sql.SQLException;

public class App {
    public static void main(String[] args) throws SQLException {
        ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);

        /*UserService userService = ctx.getBean(UserService.class);
        userService.save();
        UserDao userDao = (UserDao) ctx.getBean("userDao");
        userDao.save();
        BookDao bookDao = (BookDao) ctx.getBean("bookDao");
        bookDao.save();*/

        UserService userService = (UserService) ctx.getBean("userService");
        userService.save();

    }
}
